<template>
	<v-forms ref="formRef">
		<template #tint1="scope">
			<el-Divider content-position="left" style="margin: 5px 0px"
				><span style="color: #1a63db; font-weight: bold">{{ scope.data.item.label }}</span></el-Divider
			>
		</template>
		<template #cgdm>
			<v-table ref="xxx" :data-list="tableData" v-bind="detailDistrubuteTableConfig" v-model:page="pageInfo" :dataCount="Number(totalRows)"> </v-table>
		</template>

		<template #attachmentPath>
			<div v-if="contractURL">
				<el-icon size="12">
					<ele-Link />
				</el-icon>
				<a :href="`${baseURL}/${contractURL}`" style="color: blue; text-decoration: underline" target="_blank">{{ $t('2q60GtaOAtU0Jcx1vJmf') }}</a>
			</div>
		</template>
	</v-forms>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { VForms, detailDistrubuteFormConfig, detailDistrubuteTableConfig, vTable } from '../config/index';
import useCurrentInstance from '/@/utils/hook/useCurrentInstance';
const { proxy } = useCurrentInstance();
const $t = proxy.$t;

import { getDistributeDetail } from '/@/api/platformWork/index';
const baseURL = import.meta.env.VITE_API_URL;
let contractURL = ref(''); //附件地址
const formRef = ref();
const tableData: any = ref([]);
const totalRows: any = ref(0);
const pageInfo = ref({
	currentPage: 1,
	pageSize: 10,
});

//新增数据变更
const addNew = async (data: any) => {
	const res: any = await getDistributeDetail({ id: data.id });
	let list: any = detailDistrubuteFormConfig(res.data);
	tableData.value = res.data.cgdm;
	totalRows.value = res.data.cgdm.length;
	contractURL.value = res.data.mApply?.attachmentPath || '';
	formRef.value.openDialog(list, $t('8xIj08X7u5QerhqXVuKj'));
};

defineExpose({
	addNew,
});
</script>
<scope lang="scss" scoped></scope>
